package com.atguigu3.common_algorithm.exer1;

/**
 * @author NoobMaster69  * @date 2024/5/25 0025 星期六 11:18
 */
public class ArrayTest {
    public static void main(String[] args) {
        int[] arr = new int[10];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * (99 - 10 + 1) + 10);
            System.out.print(arr[i] + "\t");
        }
        System.out.println();

        //最大值
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];

            }
        }
        System.out.println("最大值：" + max);
        //最小值
        int min = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (min > arr[i]) {
                min = arr[i];
            }
        }
        System.out.println("最小值：" + min);
        //总和
        int sum = arr[0];
        for (int i = 1; i < arr.length; i++) {
            sum += arr[i];
        }
        System.out.println("总和："+sum);

        //平均值
        int avgVail = sum / arr.length;
        System.out.println("平均值：" + avgVail);
    }
}
